package com.docker.apps.afterservice.ui;

import android.arch.lifecycle.ViewModelProviders;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.dcbfhd.utilcode.utils.ToastUtils;
import com.docker.apps.R;
import com.docker.apps.databinding.ProInvoiceDetailActivityBinding;
import com.docker.apps.order.utils.OrderBdUtils;
import com.docker.apps.afterservice.vm.AfterServiceViewModel;
import com.docker.apps.order.vo.InvoiceVo;
import com.docker.apps.order.vo.InvoiceVov2;
import com.docker.apps.order.vo.OrderVoV2;
import com.docker.common.common.config.ThiredPartConfig;
import com.docker.common.common.router.AppRouter;
import com.docker.common.common.ui.base.NitCommonActivity;
import com.docker.common.common.utils.cache.CacheUtils;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * kxf -> 2020-03-03
 **/

@Route(path = AppRouter.ORDER_INVOICE)//售后服务
public class InvoiceOrderDetailActivity extends NitCommonActivity<AfterServiceViewModel, ProInvoiceDetailActivityBinding> {


    private String invoiceid;

    @Override
    public void initView() {
        mToolbar.setTitle("发票详情");
//        String orderid = getIntent().getStringExtra("orderid");
        invoiceid = getIntent().getStringExtra("invoiceid");
        HashMap<String, String> param = new HashMap<>();
        param.put("memberid", CacheUtils.getUser().uid);
        param.put("uuid", CacheUtils.getUser().uuid);
        param.put("invoiceId", invoiceid);
        mViewModel.invoiceShow(param);


    }

    @Override
    public void initObserver() {
        mViewModel.mServerLiveData.observe(this, o -> {
            InvoiceVov2 invoiceVo = (InvoiceVov2) o;
            if (invoiceVo == null)
                return;

            switch (invoiceVo.status) {
                case "0":
//                    statustr = "发票申请中";

                    break;
                case "1":

                    mBinding.invoiceI2.setImageResource(R.mipmap.fapiao_check);
                    mBinding.invoiceI3.setBackgroundColor(Color.parseColor("#C2C2C2"));
                    mBinding.invoiceI4.setImageResource(R.mipmap.fapiao_no);
                    mBinding.invoiceT1.setTextColor(Color.parseColor("#2FBF56"));
                    mBinding.invoiceT1.setVisibility(View.VISIBLE);

//                    statustr = "商家已开票";
                    break;
                case "2":
                    mBinding.invoiceI2.setImageResource(R.mipmap.fapiao_check);
                    mBinding.invoiceI3.setBackgroundColor(Color.parseColor("#2FBF56"));
                    mBinding.invoiceI4.setImageResource(R.mipmap.fapiao_check);
                    mBinding.invoiceT1.setTextColor(Color.parseColor("#2FBF56"));
                    mBinding.invoiceT1.setVisibility(View.VISIBLE);
                    mBinding.invoiceT2.setTextColor(Color.parseColor("#2FBF56"));
//                    statustr = "已完成";
                    break;
                case "3":
//                    statustr = "商家已驳回";
                    mBinding.invoiceI2.setImageResource(R.mipmap.fapiao_no);
                    mBinding.invoiceI1.setBackgroundColor(Color.parseColor("#C2C2C2"));
                    mBinding.invoiceI3.setVisibility(View.GONE);
                    mBinding.invoiceI4.setVisibility(View.GONE);
                    mBinding.invoiceT1.setTextColor(Color.parseColor("#C2C2C2"));
                    mBinding.invoiceT1.setVisibility(View.VISIBLE);
                    mBinding.invoiceT1.setText("商家已驳回");
                    mBinding.invoiceT2.setVisibility(View.GONE);
                    break;
            }

            mBinding.setItem(invoiceVo);
        });

    }

    @Override
    public void initRouter() {
        ARouter.getInstance().inject(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.pro_invoice_detail_activity;
    }

    @Override
    public AfterServiceViewModel getmViewModel() {
        return ViewModelProviders.of(this, factory).get(AfterServiceViewModel.class);
    }
}